Database management system, computer, and database management method

ABSTRACT

A database management system (DBMS) generates a query execution plan including information representing one or more database (DB) operations necessary for executing a query and executes the query based on the query execution plan. In the execution of the query, the DBMS dynamically generates a task for executing a DB operation and executes the dynamically generated task. The DBMS executes a task in a plurality of threads executed by a processor core.

TECHNICAL FIELD

The present invention relates to a data management technique.

BACKGROUND ART

In enterprise activities, utilization of a large amount of generatedbusiness data is indispensable. Therefore, a system that analyzes adatabase (hereinafter, “DB”) that stores a large amount of business datahas already been devised.

In this analysis processing, a database management system (hereinafter,“DBMS”) receives a query and issues a data read request to a storagedevice that stores a DB.

As a technique of reducing latency for a data read in a processing forone query, a technique disclosed in PTL 1 is known. According to PTL 1,a DBMS generates a plan (hereinafter, “query execution plan”) which is acombination of a plurality of database operations (called DB operationsor processing steps) necessary for executing a query, dynamicallygenerates tasks for executing the processing steps, and concurrentlyexecutes the tasks to multiplex a data read request. For implementationof the task, according to PTL 1, any execution environment such as aprocess or thread managed by an OS or a pseudo process or pseudo threadimplemented by an application or middleware can be used.

CITATION LIST Patent Literature

[PTL 1] Japanese Patent Application Publication No. 2007-34414

SUMMARY OF INVENTION Technical Problem

In the case where the number of data stored in a DB is several tens ofthousands, there are cases where several tens of thousands of tasks aregenerated with respect to a processing for one query. When a task insuch a case is implemented with a thread (or process), several tens ofthousands of threads are generated. Since a thread is executed on anarbitrary processor core in a computer having a plurality of processorcores, an arbitrary processor core updates a management structure of athread. Therefore, the overhead for management of thread executionincreases. As a result, there is a problem that the execution time ofthe query is increased.

When a task is implemented with a pseudo thread (or pseudo process), thetask is supposed to be implemented with one thread (or process). Since amanagement structure of a pseudo thread is updated by only one threadeven if several tens of thousands of pseudo threads are generated, themanagement overhead is small. However, in the case where a computer hasa plurality of processor cores, only one processor core is used, sincethere is one thread. Therefore, since only one processor core can beused in the case where many processing operations by a processor coreare necessary in order to execute a processing step, there is a problemthat the execution time of a query is increased.

Thus, an object of the present invention is to use a plurality ofprocessor cores for a DBMS and reduce the management overhead of athread.

Solution to Problem

The DBMS is realized by a computer including a processor core andmanages a DB. The DBMS includes a query reception unit that receives aquery to the DB, a query execution plan generation unit that generates aquery execution plan including information representing a processingstep necessary for executing the received query and an executionprocedure of the processing step, and a query execution unit thatexecutes the received query based on the generated query execution planand, in an execution of the received query, dynamically generates a taskfor executing a processing step to execute the dynamically generatedtask.

The query execution unit, in an execution of the received query,executes a task in a plurality of threads executed by a processor coreand executes a plurality of tasks in one thread executed by theprocessor core. For example, in the execution of a query, the queryexecution unit may dynamically generate a task for executing a databaseoperation and execute the dynamically generated task. For example, inthe execution of a query, the query execution unit may perform (a)generating a task for executing a database operation, (b) executing thegenerated task to issue a data read request to a database in order toread data necessary in the database operation corresponding to the task,(c) in the case of executing an (N+1)th database operation based on anexecution result of an N-th database operation (N is an integer of 1 orgreater) corresponding to the task executed in (b) described above,newly generating a task based on the execution result, and (d)performing of (b) and (c) for the newly generated task. In the casewhere two or more ready tasks exist in (b) and (d), at least two tasksout of the two or more tasks may be executed concurrently.

The query execution unit generates a context when newly generating atask, and executes the generated task based on the generated context.The context is information including first information showing aprocessing step for starting an execution in the newly generated task iswhich of one or more processing steps represented by the query executionplan, second information relating to an access destination for datarequired in a processing step shown by the first information, and thirdinformation relating to data necessary for generating a result by thenewly generated task.

Advantageous Effects of Invention

According to the present invention, a plurality of processor cores isused and the management overhead of a thread is reduced by executing aplurality of tasks by one thread and by executing the query by aplurality of threads As a result, the execution time of a query can bereduced.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a view illustrating the outline of a DBMS according toEmbodiment 1.

FIG. 2 is a view illustrating the execution of a query in a DBMSaccording to Embodiment 1.

FIG. 3 is a configuration diagram of a computer system according toEmbodiment 1.

FIG. 4 is a view illustrating the definition of a table and index of aDB according to Embodiment 1.

FIG. 5 is a view showing one example of a Part table of a DB accordingto Embodiment 1.

FIG. 6 is a view showing one example of a Lineitem table of a DBaccording to Embodiment 1.

FIG. 7 is a view illustrating one example of a data structure of a Partindex and Part table in a DB according to Embodiment 1.

FIG. 8 is a view showing one example of a query of a DB according toEmbodiment 1.

FIG. 9 is a view showing one example of a query execution plan accordingto Embodiment 1.

FIG. 10 is a view showing one example of a data structure of taskmanagement information according to Embodiment 1.

FIG. 11 is a view showing one example of task execution stateinformation according to Embodiment 1.

FIG. 12 is a view showing a first example of processing step executionstate information according to Embodiment 1.

FIG. 13 is a view showing a second example of processing step executionstate information according to Embodiment 1.

FIG. 14 is a view showing a third example of processing step executionstate information according to Embodiment 1.

FIG. 15 is a view illustrating one example of a data structure ofcontext management information according to Embodiment 1.

FIG. 16 is a view showing one example of a thread #1 specific searchtable according to Embodiment 1.

FIG. 17 is a view showing one example of a thread #2 specific searchtable according to Embodiment 1.

FIG. 18 is a view showing one example of a thread #3 specific searchtable according to Embodiment 1.

FIG. 19 is a view showing one example of a context according toEmbodiment 1.

FIG. 20 is a flowchart of a processing at the time of query acceptanceaccording to Embodiment 1.

FIG. 21 is a flowchart of a query execution plan generation processingaccording to Embodiment 1.

FIG. 22 is a flowchart of an inter-thread sharing flag settingprocessing according to Embodiment 1.

FIG. 23 is a view illustrating another example of a query execution planaccording to Embodiment 1.

FIG. 24 is a flowchart of a result transmission processing according toEmbodiment 1.

FIG. 25 is a flowchart of a thread execution processing according toEmbodiment 1.

FIG. 26 is a flowchart of a task execution processing according toEmbodiment 1.

FIG. 27 is a flowchart of a context search processing according toEmbodiment 1.

FIG. 28 is a flowchart of a query execution plan execution processingaccording to Embodiment 1.

FIG. 29 is a flowchart of a DB page fetch processing according toEmbodiment 1.

FIG. 30 is a flowchart of a new task addition processing according toEmbodiment 1.

FIG. 31 is a flowchart of a context sharing determination processingaccording to Embodiment 1.

FIG. 32 is a flowchart of a context registration processing according toEmbodiment 1.

FIG. 33 is a flowchart of a task generation processing according toEmbodiment 1.

FIG. 34 is a flowchart of a load balance processing according to amodified example.

FIG. 35 shows the configuration of a computer system according toEmbodiment 2.

DESCRIPTION OF EMBODIMENTS Embodiment 1

First, the outline of Embodiment 1 will be described.

FIG. 1 is a view illustrating the outline of a DBMS according toEmbodiment 1.

A DBMS 141 includes a client communication control unit 142, a queryexecution plan 143, a query execution unit 144, an execution taskmanagement unit 145, a thread management unit 146, and a DB buffermanagement unit 147. The query execution unit 144 includes a queryexecution plan execution unit 151, a context management unit 152, and acontext sharing determination unit 153.

In the execution of a query, the DBMS 141 (query execution unit 144)dynamically generates a task for executing a processing step andexecutes the dynamically generated task. Specifically, in the executionof a query, for example, the DBMS 141 (query execution unit 144)performs (a) generating a task for executing a processing step, (b)executing the generated task to issue a data read request to a DB inorder to read data necessary in the processing step corresponding to thetask, (c) in the case of executing an (N+1)th processing step based onan execution result of an N-th processing step (N is an integer of 1 orgreater) corresponding to the task executed in (b) described above,newly generating a task based on the execution result, and (d)performing of (b) described above and (c) described above for the newlygenerated task. In the case where two or more ready tasks exist in (b)and (d) described above, at least two tasks out of the two or more taskscan be executed concurrently.

Upon executing a task, the DBMS 141 (query execution unit 144) uses aplurality of threads (kernel threads) provided by an operating system(OS), and the plurality of threads are respectively executed by one or aplurality of processor cores included in one or a plurality ofprocessors. By the processor core executing a thread, a task assigned tothe thread is executed. Hereinafter, an expression such as a processorcore executes a task or the DBMS 141 executes a task means executing atask assigned to the thread by executing the thread by a processor core.

The DBMS 141 receives a query via the client communication control unit142. The query execution plan generation unit 143 generates a queryexecution plan PL for executing the received query. The query executionplan execution unit 151 executes the generated query execution plan PL.The thread management unit 146 manages a plurality of threads executedby a processor core of a processor in a computer in which the DBMS 141is configured. The execution task management unit 145 manages a taskexecuted with a thread. In this embodiment, the execution taskmanagement unit 145 can assign a plurality of tasks to one thread.Accordingly, the overhead required for management of a thread can bereduced.

The context management unit 152 manages a context used upon execution ofa task. As a context, there are a context shared between threads that ismanaged to be usable from a plurality of threads and a context notshared between threads that is managed to be usable from only onethread. A thread that can use a context not shared between threads canuse the context preferentially compared to other threads.

In an example in FIG. 1, context #0 and context #1 are contexts sharedbetween threads, and context #2, context #3, and context #4 are contextsnot shared between threads. Upon executing a task assigned to thread #1,thread #2, and thread #3, context #0 and context #1 are used. Uponexecuting a task assigned to thread #1, context #2 is used. Uponexecuting a task assigned to thread #2, context #3 is used. Uponexecuting a task assigned to thread #3, context #4 uses context #4.

Whether a context is to be shared between threads or not shared betweenthreads is determined based on the result of determination by thecontext sharing determination unit 153. For example, the context sharingdetermination unit 153 may assume a context relating to a processingstep at the start of a query execution plan to be a context sharedbetween threads. In the case where a query execution plan is configuredof a plurality of processing blocks concurrently executable, the contextsharing determination unit 153 may assume a context relating to a firstprocessing step of each processing block to be a context shared betweenthreads. The context sharing determination unit 153 may assume a contextrelating to a processing step with a predetermined number or greaternumber of subsequent processing steps in one processing block to be acontext shared between threads. A processing block may be configured ofone or more processing steps. One example of a query execution planconfigured of a plurality of processing blocks concurrently executablewill be described later.

FIG. 2 is a view illustrating the execution of a query in a DBmanagement system according to Embodiment 1. In the drawing, the passageof time is expressed from the top toward the lower direction.

First, the thread management unit 146 generates thread #1, thread #2,and thread #3. It is possible to concurrently execute threads #1 to #3with different processor cores, for example. The query execution planexecution unit 151 (specifically, one processor core) generates context#0 with which execution of a query is started and generates task #1.Context #0 is a context relating to processing step #1 at the start of aquery execution plan and therefore is shared between threads. The queryexecution plan execution unit 151 assigns task #1 to thread #1. Thread#1 uses context #0 to execute task #1. When task #1 is executed, context#1 is generated, and task #2 and task #3 are generated. Context #1 is acontext relating to processing step #1 at the start of the queryexecution plan and therefore is shared between threads. Thread #1assigns task #2 to thread #2 and assigns task #3 to thread #3. Thread #2uses context #1 to execute task #2. Thread #3 uses context #1 to executetask #3.

Thread #1 executes task #1 and executes an access processing for a DB.As a result, a new context is generated. For example, context #2relating to processing step #3 is generated. The processing step ofcontext #2 is not at the start of the query execution plan and thereforeis not shared between threads. That is, context #2 is basically used bythread #1. Thread #1 generates and assigns, to thread #1, task #4.Thread #1 uses context #2 to execute task #4.

Thread #2 executes task #2 and executes an access processing for a DB.As a result, a new context is generated. For example, context #3relating to processing step #3 is generated. The processing step ofcontext #3 is not at the start of the query execution plan and thereforeis not shared between threads. That is, context #3 is basically used bythread #2. Thread #2 generates and assigns, to thread #2, task #5 andtask #6. Thread #2 uses context #3 to execute task #5. Further, thread#2 uses context #3 to execute task #6.

Thread #3 executes task #3 and executes an access process for a DB. As aresult, a new context is generated. For example, context #4 relating toprocessing step #3 is generated. The processing step of context #4 isnot at the start of the query execution plan and therefore is not sharedbetween threads. That is, context #4 is basically used by thread #3.Thread #3 generates and assigns, to thread #3, task #7 and task #8.Thread #3 uses context #4 to execute task #7. Further, thread #3 usescontext #4 to execute task #8.

In this manner, one thread executes a plurality of tasks, and a query isexecuted with a plurality of threads. As a result, the execution time ofthe query can be reduced, since a plurality of processor cores are usedand the management overhead of a thread is reduced.

Embodiment 1 will be described in detail.

FIG. 3 is a configuration diagram of a computer system according toEmbodiment 1.

The computer system includes a computer 100 and an external storageapparatus 200. The computer 100 and the external storage apparatus 200are connected via a communication network 300. As a protocol forcommunication via the communication network 300, FC (Fibre Channel),SCSI (Small Computer System Interface), IB (Infini Band), or TCP/IP(Transmission Control Protocol/Internet Protocol) may be employed, forexample.

The computer 100 is, for example, a personal computer, a workstation, ora main frame. The computer 100 includes a network adapter 110, aprocessor (typically, microprocessor (e.g., CPU (Central ProcessingUnit)) 120, a local storage device 130, and a memory 140. The processor120 executes a computer program, e.g., an OS (Operating System) that isnot shown or the DBMS 141. One or multiple processors 120 include one ora plurality of processor cores. The respective processor cores are eachcapable of executing processing independently. A processor core has acache with shorter access latency than the memory 140. A processor coreholds, in a cache, data recorded in the memory 140 to perform processingof the data. In the case where one processor core processes the samedata consecutively, the processing time is shorter compared to a casewhere different processor cores process the same data consecutively,since data held in a cache can be used. Basically, in this embodiment,each processor core can execute one thread (kernel thread) at a giventime point. The memory 140 temporarily stores a program executed by theprocessor 120 and data used by the program. In this embodiment, thememory 140 stores the DBMS 141 as a program that performs management ofa DB or a relevant processing sequence and data. The memory 141 maystore an AP (Application Program) 148 for issuing a query to the DBMS141. The local storage device 130 stores a program and data used by theprogram. The network adapter 110 connects the communication network 300and the computer 100. The processor 120 may be a component included in acontrol device coupled to the network adapter 110, the memory 140, andthe like. The control device may include, in addition to the processor120, a dedicated hardware circuit (e.g., circuit that performsencryption and decryption of data).

In terms of performance and redundancy, the computer 100 may include aplurality of components, for at least one of the network adapter 110,the processor 120, the local storage device 130, and the memory 140. Thecomputer 100 may include an input device (e.g., keyboard and pointingdevice) and a display device (e.g., liquid crystal display) that are notshown. The input device and the display device may be integrated.

In the computer 100, the DBMS 141 executes a query issued with respectto the DBMS 141. The query is issued by the AP 148 executed by thecomputer 100 or an AP executed by a computer (client) that is not shownand coupled to the communication network 300. The DBMS 141 executes aquery issued by the AP 148 and, along with the execution of the query,transmits an I/O request with respect to a DB 206 stored in the externalstorage apparatus 200 to the external storage apparatus 200 via an OS.The OS may be an OS that runs on a virtual machine created and executedby a virtualization program.

The external storage apparatus 200 stores data used by the computer 100.The external storage apparatus 200 receives an I/O request from thecomputer 100, executes a processing corresponding to the I/O request,and transmits the processing result to the computer 100.

The external storage apparatus 200 includes a network adapter 201, astorage device group 203, and a controller 202 connected thereto.

The network adapter 201 connects the external storage apparatus 200 tothe communication network 300.

The storage device group 203 includes one or more storage devices. Astorage device is a non-volatile storage medium, e.g., a magnetic disk,a flash memory, or other semiconductor memories. The storage devicegroup 203 may be a group storing data in a predetermined RAID level,according to RAID (Redundant Array of Independent Disks). A logicalstorage device (logical volume) based on a storage space in the storagedevice group 203 may be provided to the computer 100. The storage devicegroup 203 stores the DB 206. The DB 206 includes one or more tables 204or indexes 205. A table is a set of one or more records, and a record isconfigured of one or more columns. An index is a data structure that isintended and created for one or more columns within a table to increasethe speed of access to a table with a selecting condition including acolumn for which the index is intended. For example, an index is a datastructure holding, for each value of an intended column, information(Row ID) with which a record within a table including the value isidentified. A B-tree structure or the like is used. The configurationexample of a table of a DB and one example of the relationship of tableswill be described later.

The controller 202 includes, for example, a memory and a processor.According to an I/O request from the computer 100, data is input to oroutput from the storage device group 203 storing the DB 206. Forexample, the controller 202 stores, in the storage device group 203,data of a write target according to a write request from the computer100 or reads, from the storage device group 203, data of a read targetaccording to a read request from the computer 100 to transmit the datato the computer 100.

The external storage apparatus 200 may include a plurality of componentssuch as the controllers 202, in terms of ensuring performance andredundancy. Multiple external storage apparatuses 200 may be included.

The DBMS 141 manages the DB 206 including business data. The DBMS 141includes the client communication control unit 142, the query executionplan generation unit 143, the query execution unit 144, the executiontask management unit 145, the thread management unit 146, and the DBbuffer management unit 147.

The client communication control unit 142 controls communication with aclient coupled to the communication network 300 or the AP 148.Specifically, the client communication control unit 142 receives(accepts) a query issued from a client or the AP 148 and executes aprocessing of transmitting the processing result of the query to theclient or the AP 148. The query is written in SQL (Structure QueryLanguage), for example.

The query execution plan generation unit 143 generates a query executionplan including one or more processing steps necessary for executing aquery received by the client communication control unit 142. A queryexecution plan is, for example, information in which the order ofexecution of processing steps to be performed upon execution of a queryis defined with a tree structure, and is stored in the memory 140. Oneexample of a query execution plan will be described later.

The DB buffer management unit 147 manages a storage area (DB buffer) fortemporarily storing data within the DB 206. A DB buffer is configured inthe memory 140. A DB buffer may be configured in the local storagedevice 130.

The query execution unit 144 executes a query according to a queryexecution plan generated by the query execution plan generation unit 143and returns the generated result to an issue source of the query. Thequery execution unit 144 includes the query execution plan executionunit 151, the context management unit 152, and the context sharingdetermination unit 153.

The query execution plan execution unit 151 dynamically generates a taskfor executing a processing step within a query execution plan, assigns atask to a thread, and executes a query through execution of the taskwith the thread.

The context management unit 152 manages a context including informationnecessary in the execution of a generated task. A context is informationincluding first information showing a processing step for startingexecution in a task is which of one or more processing steps representedby a query execution plan, second information relating to an accessdestination for data required in the processing step shown by the firstinformation, and third information relating to data necessary forgenerating a result with the task. The structure of the contextmanagement information that is information for managing a context willbe described later.

The context sharing determination unit 153 determines whether or not acontext is to be shared between a plurality of threads.

The execution task management unit 145 manages a task executed by athread. A task is, for example, a pseudo process or pseudo thread(user-level thread) implemented by a DBMS 412. A task may be a set ofpointers (function pointers) to a function in which each processing issummarized as a function. The structure of task management informationthat is information for managing a task will be described later.

The thread management unit 146 manages a thread for executing a query. Athread is a thread (kernel thread) provided an OS. As described above, atask assigned to a thread is executed by a processor core executing thethread that is assigned. A process may be used instead of a thread.

At least a part of processing performed by at least one processing unitof the client communication control unit 142, the query execution plangeneration unit 143, the query execution unit 144, and the DB buffermanagement unit 147 may be performed with hardware. In the case wherethe processing unit is a subject in the description in this embodiment,processing is actually performed by the processor 120 that executes theprocessing unit. However, in the case where at least a part of theprocessing unit is realized by hardware, the hardware may be a subjectinstead of or in addition to the processor 120. A computer program thatrealizes the DBMS 141 may be installed in the computer 100 from aprogram source. A program source may be a storage medium readable by thecomputer 100 or may be another computer, for example.

The configuration of the DBMS 141 shown in FIG. 3 is one example. Forexample, it may be such that a certain processing unit is divided into aplurality of processing units or one processing unit in which functionsof a plurality of processing units are integrated is configured.

FIG. 4 is a view illustrating the definition of a table and index of aDB according to Embodiment 1.

The DB 206 includes, for example, as Table 205 a Part table includingcolumn c1 and column c2 and a Lineitem table including column c3 andcolumn c4. The DB 206 includes, as the index 204, an index (Part index)relating to the Part table based on the value of column c1 and an index(Lineitem index) relating to the Lineitem table based on the value ofcolumn c3.

FIG. 5 is a view showing one example of a Part table of a DB accordingto Embodiment 1.

The Part table of the DB 206 is logically a table in which the value ofcolumn c1 and the corresponding value of column c2 are associated, forexample.

FIG. 6 is a view showing one example of a Lineitem table of a DBaccording to Embodiment 1.

The Lineitem table of the DB 206 is a table in which the value of columnc3 and the corresponding value of column c4 are associated, for example.

FIG. 7 is a view illustrating one example of a data structure of a Partindex and Part table in a DB according to Embodiment 1.

The Part index is, for example, in a B-tree structure to search for apage and slot of the Part table storing the corresponding value ofcolumn c2 based on the value of column c1. A page is the minimum dataunit in the input and output with respect to the DB 206. In thisembodiment, the Part index manages page P in a hierarchical structure.In the Part index, there are a leaf page that is a page at the lowestlevel and a higher-level page that is a page at a higher level than aleaf page. A page at the highest level among the higher-level pages isreferred to as a root page.

The root page (page P1) of the Part index is provided with one or moreentries in which a pointer with respect to a page on a level immediatelybelow and the maximum value for the value of column c1 as a managementtarget of the page on the level immediately below are associated. Forexample, page P1 stores a pointer to page P2 managing the correspondencerelationship with respect to the value of column c1 that is less than orequal to “100,” a pointer to page P3 managing the correspondencerelationship with respect to the value of column c1 that is greater than“100” and less than or equal to “200,” and a pointer to page P4 managingthe correspondence relationship with respect to the value of column c1that is greater than “200” and less than or equal to “300.” In a similarmanner, a higher-level page is provided with one or more entries inwhich a pointer with respect to a page on a level immediately below eachpage and the maximum value for the value of column c1 managed in thepage on the level immediately below are associated.

A leaf page stores one or more rows (records) in which the value ofcolumn c1 and the storage location (e.g., a page number of the Parttable and a slot number within the page) in the Part table storing thevalue of column c2 corresponding to the value are associated.

For example, page P8 that is a leaf page stores a row including thenumber of a page and slot storing the value of column c2 correspondingto the value “110” of column c1 and a row including the number of a pageand slot storing the value of column c2 corresponding to the value “130”of column c1. For example, as the row including the number of the pageand slot storing the value of column c2 corresponding to the value “130”of column c1, rows showing slot 2 in page P100, slot 1 in page P120, andslot 4 in page P200 are stored. Thus, the values of column c2corresponding to the value “130” of column c1 are “id131” from a recordof slot 2 in page P100 of the Part table, “id132” from a record of slot1 in page P120 of the Part table, and “id133” from a record of slot 4 inpage 200 of the Part table.

FIG. 8 is a view showing one example of a query of a DB according toEmbodiment 1.

The query shown in FIG. 8 is one example of a query with respect to theDB 206 with the structure shown in FIG. 4 to FIG. 7. The query shown inFIG. 8 means that the value of column c1 and the value of column c4 areextracted from the Part table and the Lineitem table where the value ofcolumn c1 is “130” and the value of column c2 and the value of column c3are the same.

FIG. 9 is a view showing one example of a query execution plan accordingto Embodiment 1.

The query execution plan shown in the figure shows a query executionplan generated by the query execution plan generation unit 143 in thecase where the DBMS 141 has received the query shown in FIG. 8.

As shown in FIG. 9, the query execution plan corresponding to the queryshown in FIG. 8 includes processing step #1 of performing an indexsearch with the Part index, processing step #2 of acquiring a recordfrom the Part table, processing step #3 of performing an index searchwith the Lineitem index, processing step #4 of acquiring a record fromthe Lineitem table, and processing step #5 of performing a nested loopjoin with the results.

FIG. 10 is a view showing one example of a data structure of taskmanagement information according to Embodiment 1.

The task management information includes a main data structure 71. Themain data structure 71 associates and stores, for each thread, threadidentification information (e.g., thread number) with which a pluralityof threads are identified and a pointer to a list management structure72 with which a task executed by a thread is managed.

The list management structure 72 stores a ready list 72 a for managing aready task in a corresponding thread and a waiting list 72 b formanaging a task in a waiting state in a corresponding thread. The readylist 72 a includes a pointer to execution state information (taskexecution state information) 73 relating to a ready task in acorresponding thread. The task execution state information 73 includes apointer to the task execution state information 73 relating to anotherready task in a correspond thread.

For example, in FIG. 10, execution state information (task #2 executionstate information) with respect to task #2 is managed as the taskexecution state information 73 relating to a ready task in thread #2,and the task execution state information 73 of task #5 and task #6 ismanaged as the task execution state information 73 relating to a task ina waiting state in thread #2. In the case where tasks are uneven betweena plurality of threads, a task (i.e., the task execution stateinformation 73) may be transferred to a list of another thread.

In this embodiment, a ready list and a waiting list are managed for eachthread. However, a ready list and a waiting list may be shared between aplurality of threads. A ready list and a waiting list may be managed foreach processing step.

FIG. 11 is a view showing one example of task execution stateinformation according to Embodiment 1.

The task execution state information 73 stores a work area 73 a, aprocessing step 73 b, and a processing step execution state 73 c. Thework area 73 a stores a pointer showing a work area. The processing step73 b stores information, e.g., a processing step number, with which aprocessing step executed by a corresponding task is identified. Theprocessing step execution state 73 c stores execution state information(processing step execution state information) 74 of a correspondingprocessing step. A specific example of the processing step executionstate information 74 will be described later.

FIG. 12 is a view showing a first example of processing step executionstate information according to Embodiment 1. FIG. 12 shows processingstep execution state information for a task that uses a higher-levelpage in an index search.

Processing step execution state information 74A includes a searchcondition 74 a, a page number 74 b, and a slot number 74 c. The searchcondition 74 a stores a search condition. In the example in the figure,the search condition 74 a stores a range “115≦key≦195” for a key valuethat is a search condition included in a query. The page number 74 bstores a number (page number) of a higher-level page used in processingof a task. The slot number 74 c stores a number (slot number) of a slotin a page used in processing of a task.

FIG. 13 is a view showing a second example of processing step executionstate information according to Embodiment 1. FIG. 13 shows processingstep execution state information for a task that uses a leaf page in anindex search.

Processing step execution state information 74B includes a searchcondition 74 d, a page number 74 e, a slot number 74 f, and a processingrow ID number 74 g. The search condition 74 d stores a search condition.

In the example in the figure, the search condition 74 d stores a range“115≦key≦195” for a key value that is a search condition. The pagenumber 74 e stores a page number of a leaf page used in processing of atask. The slot number 74 f stores a slot number of a slot in a page usedin processing of a task. The processing row ID number 74 g stores an IDnumber (processing row ID number) of a row within a slot processed witha corresponding task.

FIG. 14 is a view showing a third example of processing step executionstate information according to Embodiment 1. FIG. 14 shows processingstep execution state information for a task that performs record fetch.

Processing step execution state information 74C includes a page number74 h and a slot number 74 i. The page number 74 h stores a page numberof a page used in processing of a task. The slot number 74 i stores aslot number of a slot in a page used in processing of a task.

FIG. 15 is a view illustrating one example of the data structure ofcontext management information according to Embodiment 1.

Context management information 80 includes a main structure 81 of amanagement list and a plurality of contexts 82. The main structure 81stores a pointer to the context 82. Each context 82 stores a pointer toanother context 82. In this embodiment, a thread executing a taskperforms a lock in units of the respective contexts 82, in the case ofusing the context 82 in processing of the task. A context in a lockedstate cannot be used by another thread.

The context management information 80 stores search tables (threadspecific search tables) 83, 84, 85, and the like corresponding to athread executing a query. The thread #1 specific search table 83 managesa pointer to the context 82 available to thread #1. The thread #2specific search table 84 manages a pointer to the context 82 availableto thread #2. The thread #3 specific search table 85 manages a pointerto the context 82 available to thread #3.

FIG. 16 is a view showing one example of a thread #1 specific searchtable according to Embodiment 1. FIG. 17 is a view showing one exampleof a thread #2 specific search table according to Embodiment 1. FIG. 18is a view showing one example of a thread #3 specific search tableaccording to Embodiment 1.

The thread #1 specific search table 83 is a table managing a pointer toa context available to thread #1 and manages a list of pointers tocontexts relating to respective processing steps. As shown in FIG. 16, apointer 83 a to a context relating to processing step #1, a pointer 83 bto a context relating to processing step #2, a pointer 83 c to a contextrelating to processing step #3, and a pointer 83 d to a context relatingto processing step #4 are included. In this embodiment, the pointer 83 astores a pointer to context #1, and the pointer 83 c stores a pointer tocontext #2.

The thread #2 specific search table 84 is a table managing a pointer toa context available to thread #2 and manages a list of pointers tocontexts relating to respective processing steps. As shown in FIG. 17, apointer 84 a to a context relating to processing step #1, a pointer 84 bto a context relating to processing step #2, a pointer 84 c to a contextrelating to processing step #3, and a pointer 84 d to a context relatingto processing step #4 are included. In this embodiment, the pointer 84 astores a pointer to context #1, and the pointer 84 c stores a pointer tocontext #3.

The thread #3 specific search table 85 is a table managing a pointer toa context available to thread #3 and manages a list of pointers tocontexts relating to respective processing steps. As shown in FIG. 18, apointer 85 a to a context relating to processing step #1, a pointer 85 bto a context relating to processing step #2, a pointer 85 c to a contextrelating to processing step #3, and a pointer 85 d to a context relatingto processing step #4 are included. In this embodiment, the pointer 85 astores a pointer to context #1, and the pointer 85 c stores a pointer tocontext #4.

According to the thread #1 specific search table 83, the thread #2specific search table 84, and the thread #3 specific search table 85,context #1 is available to thread #1, thread #2, and thread #3. Context#2 is available to thread #1. Context #3 is available to thread #2, andcontext #4 is available to thread #3. A state where a pointer to thecontext 82 is registered in a plurality of thread specific search tablesis referred to as the context being shared between threads, and a statewhere a pointer to a context is registered in one particular threadspecific search table is referred to as the context being not sharedbetween threads. A context that is available to a processor coreexecuting a certain thread, through use of a thread specific searchtable specific to the thread, is referred to as a context available tothe thread.

In this state, context #1 is used by thread #1, thread #2, or thread #3,context #2 is used by thread #1, context #3 is used by thread #2, andcontext #4 is used by thread #3. Since a context not shared betweenthreads is used consecutively by one thread in this state, theprocessing time for processing along with context use can be reducedwith a cache of a processor core.

In this embodiment, a thread specific search table specific to anotherthread may be referenced for the purpose of equalizing the amount oftasks executed by threads, in the case where available contexts areuneven between threads. Specifically, in the case where a contextavailable to a thread is absent, a thread specific search table specificto another thread is referenced, so that another thread uses a context(context #2, context #3, or context #4) not shared between threads. Forexample, in the case where a context available to thread #1 has becomeabsent in thread #1, thread #1 references the thread #2 specific searchtable or thread #3 specific search table, and context #3 or context #4is used by a task assigned to thread #1.

FIG. 19 is a view showing one example of a context according toEmbodiment 1.

The context 82 includes a starting step 82 a, an intermediate result 82b, an execution state 82 c, and a generable number 82 d. The startingstep 82 a stores the number of a corresponding processing step. Theintermediate result 82 b stores a pointer showing a work area storing anintermediate result necessary for a task that executes a correspondingprocessing step. An intermediate result is acquired data that isnecessary for generating a result of a query. The execution state 82 cstores the execution state of a task in a corresponding processing step,e.g., information (e.g., a page number 820, a slot number 821, and aprocessing row ID number 822) with which the content of processing of atask to be executed next is identified. The page number 820 stores apage number of a leaf page used in processing of the next task. The slotnumber 821 stores a slot number in a page used in processing of the nexttask. The processing row ID number 822 stores an ID number (processingrow ID number) of a row within a slot used in processing of the nexttask. The generable number 82 d stores the number of tasks (taskgenerable number) that can further be generated in a correspondingprocessing step. The task generable number is the number of processingoperations under which no task generation is implemented within thenumber of logically branched processing operations. For example, in thecase where the key value “130” is the condition for an index search withthe Part index shown in FIG. 7, there are three row IDs as entriescorresponding to the key value “130” in page P8. Therefore, as a whole,three tasks of acquiring a record of the Part table can be generatedusing the three row IDs. Since one row ID is processed with a task thatgenerates a context, the remaining two tasks can be generated from thegenerated context. Therefore, the task generable number is “2.”

FIG. 20 is a flowchart of a processing at the time of query acceptanceaccording to Embodiment 1.

Upon acceptance of a query from the AP 148 (step S1) in the processingat the time of query acceptance, the client communication control unit142 passes the received query to the query execution plan generationunit 143, and the query execution plan generation unit 143 executes aquery execution plan generation processing (see FIG. 21) (step S2).

After execution of the query execution plan generation processing, thethread management unit 146 generates a thread (step S3). The number ofthreads to be generated may be any number and may be, for example, thesame number as the number of processor cores of the processor 120. Aprocessor core that runs a thread may be designated as a particularprocessor core for each thread. That is, a processor affinity may beset. For example, the setting may be such that the same number ofthreads as the number of processor cores are generated, and eachprocessor core executes one of the threads. Accordingly, the efficiencyof processing by each thread is high. As a method of generating athread, there is a method of using an interface (function) of threadgeneration, specifically, pthread_create( ), provided by an OS.

Next, with the query execution plan execution unit 151, a context withwhich execution of a query is started is generated, and a task thatperforms processing using the context is generated and assigned to oneof the threads (step S4). For example, a task is assigned to a threadcreated first by the thread management unit 146. Accordingly,thereafter, a processor core of the processor 120 executes the thread,and the task assigned to the thread is executed by the thread.

FIG. 21 is a flowchart of a query execution plan generation processingaccording to Embodiment 1.

The query execution plan generation processing is a processingcorresponding to step S2 of the processing at the time of queryacceptance shown in FIG. 20. The query execution plan generation unit143 generates a query execution plan from the query passed from theclient communication control unit 142 (step S5). For example, in thecase where the query shown in FIG. 8 has been received, the queryexecution plan shown in FIG. 9 is generated. Next, the query executionplan generation unit 143 executes an inter-thread sharing flag settingprocessing (see FIG. 22) (step S6) and terminates the query executionplan generation processing.

FIG. 22 is a flowchart of an inter-thread sharing flag settingprocessing according to Embodiment 1.

The inter-thread sharing flag setting processing is a processingcorresponding to step S6 in the query execution plan generationprocessing shown in FIG. 21. The inter-thread sharing flag settingprocessing is a processing for setting, with respect to a predeterminedprocessing step in the query execution plan, an inter-thread sharingflag showing that a context relating to the processing step should beshared between threads.

The query execution plan generation unit 143 performs processing whilemoving a pointer in order to trace the query execution plan having atree structure. The pointer is set to the first processing step in thequery execution plan (step S11). Next, the query execution plangeneration unit 143 determines whether or not a processing step pointedby the pointer in the query execution plan is present (step S12). In thecase where a processing step pointed by the pointer is absent as aresult (“absent” in step S12), it means that processing has beenperformed for all intended processing steps in the query execution plan.Therefore, the query execution plan generation unit 143 terminates theinter-thread sharing flag setting processing. In the case where aprocessing step pointed by the pointer is present as a processing stepin the query execution plan (“present” in step S12), the query executionplan generation unit 143 determines whether or not the processing stepis at the start of a processing block (step S13).

In the case where one or more processing steps that have to be executedsequentially in a query execution plan are divided into sets that can beexecuted concurrently, a processing block refers to the set. Forexample, the query execution plan shown in FIG. 9 includes oneprocessing block. A processing block will be described using anotherquery execution plan.

FIG. 23 is a view illustrating another example of a query execution planaccording to Embodiment 1.

The query execution plan shown in FIG. 23 includes processing step #1 ofperforming an index search with a Part index, processing step #2 ofacquiring a record from a Part table, processing step #3 of executing atable scan with respect to a Lineitem table, and processing step #4 ofperforming a hash join of the results of processing step #2 andprocessing step #3. Processing step #1 and processing step #2 areprocessing operations executable concurrently with processing step #3.The query execution plan includes processing block #1 includingprocessing step #1 and processing step #2 and processing block #2including processing step #3 and processing step #4. In the queryexecution plan, processing step #1 and processing step #3 are processingsteps at the start of the processing block.

Aside from such a query execution plan, a query execution plancorresponding to a query including, for example, a subquery or a derivedtable also includes a plurality of processing blocks.

Returning to the description of FIG. 22, the query execution plangeneration unit 143 sets an inter-thread sharing flag with respect tothe processing step (step S14), in the case where the processing step isat the start of a processing block as a result of step S13 (“yes” instep S13). For example, in the query execution plan shown in FIG. 9, aninter-thread sharing flag is set to processing step #1. In the queryexecution plan shown in FIG. 23, an inter-thread sharing flag is set toprocessing step #1 and processing step #3. Then, processing proceeds tostep S15. It is considered that a context should be shared by aplurality of threads in the case where a processing step is at the startof a processing block, so that tasks at a starting point are distributedto a plurality of threads at an early stage in the processing block.

In the case where the processing step is not at the start of theprocessing block as a result step S13 (“no” in step S13), the queryexecution plan generation unit 143 proceeds to a processing of step S15.

In step S15, the query execution plan generation unit 143 moves apointer to the next processing step and proceeds to a processing of stepS12.

In the inter-thread sharing flag setting processing shown in FIG. 22, aninter-thread sharing flag is set for a processing step at the start of aprocessing block. However, for example, an inter-thread sharing flag maybe set for a processing step with a predetermined number or greaternumber of subsequent processing steps in a processing block.

FIG. 24 is a flowchart of a result transmission processing according toEmbodiment 1.

The result transmission processing is started by the clientcommunication control unit 142 after the client communication controlunit 142 has received a query. The client communication control unit 142checks the presence or absence of a result of the received query in thequery execution unit 144 (step S21).

In the case where a result of the query is present as a result(“present” in step S21), the client communication control unit 142acquires the result of the query from the query execution unit 144 (stepS22) and transmits the result of the query with respect to the AP 148that is the issue source of the query (step S26).

In the case where a result of the query is absent (“absent” in stepS21), the client communication control unit 142 determines whether aquery termination flag of the query execution unit 144 is “terminated”showing termination of the query or “not terminated” showing that thequery is not terminated (step S23). In the case where the querytermination flag is “terminated” as a result (“terminated” in step S23),NOROW (no corresponding row) is set in the result (step S24), and theresult of the query is transmitted with respect to the AP 148 that isthe issue source of the query (step S26).

In the case where the query termination flag of the query execution unit144 is “not terminated” showing non-termination of the query (“notterminated” in step S23), the client communication control unit 142waits a predetermined time for the query execution unit 144 to generatea result (step S25) and proceeds to a processing of step S21.

FIG. 25 is a flowchart of a thread execution processing according toEmbodiment 1.

The thread execution processing is realized by a processor core of theprocessor 120 executing a thread generated in step S3 in FIG. 20. In thecase where a plurality of threads exist, a different processor core canconcurrently perform a thread execution processing with respect to adifferent thread, in the case where a plurality of threads exist.

A processor core selects a task to be executed in a corresponding thread(step S31). Specifically, the processor core selects a task included ina ready list of a thread corresponding to task management informationmanaged by the execution task management unit 145.

Next, the processor core determines the presence or absence of a task tobe executed (step S32). In the case where a task to be executed isabsent (“absent” in step S32), processing proceeds to step S34. In thecase where a task to be executed is present (“present” in step S32), thetask is started or the task is resumed (step S33). Specifically, thefollowing processing is performed. The processor core selects one taskincluded in the ready list. The processor core checks task executionstate information of the selected task and starts the task or resumesthe task. In the case where a processing step of the task executionstate information is not set, processing of the task is started.Specifically, a task execution processing (see FIG. 26) is executed. Inthe case where a processing step of the task execution state informationis set, processing of the task is resumed. Specifically, execution isresumed from a processing of the task that has been interrupted. In thisembodiment, processing is resumed from step S66 in FIG. 29. After theexecution of the task has been terminated or after the execution of thetask has turned to a waiting state, the processor core proceeds to aprocessing in step S31.

In step S34, the processor core checks the presence or absence ofanother thread (step S34). In the case where another thread is absent(“absent” in step S34), termination is set in a query termination flagof the query execution unit 144 (step S35), and the thread executionprocessing is terminated. Accordingly, the thread is destroyed. In thecase where another thread is present (“present” in step S34), theprocessor core terminates the thread execution processing. Accordingly,the thread is destroyed.

FIG. 26 is a flowchart of a task execution processing according toEmbodiment 1.

The task execution processing corresponds to a processing in the casewhere processing of a task is started in step S33 in FIG. 25. The taskexecution processing is realized by a processor core executing a task ina thread.

The processor core executes a context search processing (see FIG. 27)(step S36) and checks the presence or absence of a context retrieved bythe context search processing (step S37). In the case where a context isabsent as a result (“absent” in step S37), it means that an operationfor a DB that should be executed is absent. Therefore, the taskexecution processing is terminated.

In the case where a context is present (“present” in step S37), theprocessor core sets the task execution state information 73 (see FIG.11) of the task (step S38). Specifically, the processor core copies thevalue of the starting step 82 a of the retrieved context 82 to theprocessing step 73 b of the task execution state information 73. Data ofa work area shown by a pointer of the intermediate result 82 b of thecontext is copied to a work area shown by a pointer of the work area 73a of the task execution state information 73. Further, the processorcore copies the value of the execution state 82 c of the context 82 tothe processing step execution state 73 c of the task execution stateinformation 73. For example, in the case of the context 82 shown in FIG.19, the processing step execution state 73 c of the task execution stateinformation 73 stores the value “8” of the page number 820 of thecontext 82 as the page number, stores the value “2” of the slot number821 of the context 82 as the slot number, and stores the value “2” ofthe processing row ID number 822 of the context 82 as the processing rowID number. Then, the processor core updates the execution state 82 c ofthe context 82 to correspond to the processing content in the next task.For example, in the context 82 shown in FIG. 19, the value of theprocessing row ID number 822 is incremented by one to “3.”

The task execution state information 73 shown in FIG. 19 that is set inthis manner indicates that a row ID with the processing row ID number“2” for the slot number “2” in a page (page P8 in FIG. 7) with the pagenumber “8” is referenced in the processing of the task. As a result, inthe processing thereafter, the task starts processing from referencingof a record (record having id132) storing the slot number “1” in page“P120” shown by the corresponding row ID.

After step S38, the processor core executes a query execution planexecution processing (see FIG. 28). In the case where processing of thetask has been terminated, step S39 is terminated, and the processingproceeds to step S36.

FIG. 27 is a flowchart of a context search processing according toEmbodiment 1.

The context search processing is a processing corresponding to step S36in FIG. 26. A processor core searches for a context, using a pointer ofa thread specific search table (83, 84, or 85) specific to a threadbeing executed (one's own thread) (step S41). In this embodiment, theprocessor core searches for a context in order from the last processingstep to the first processing step. Next, the processor core checks thepresence or absence of a retrieved context (step S42). In the case wherea context has been found as a result (“present” in step S42), thecontext search processing is terminated. In the case where a context isabsent (“absent” in step S42), it means that there is a possibility ofthe number of available contexts being uneven between threads.Therefore, a context is searched for using a pointer of a threadspecific search table specific to a thread (another thread) other thanone's own thread (step S43). In the case where a context is to beacquired from a thread specific search table specific to a anotherthread in this embodiment, the processor core searches for the contextin order from the first processing step to the last processing step. Thecontext is searched for from the first processing step, because there isa high possibility of the number of generated tasks being greater forthat closer to the first processing step, and thus load can bedistributed to respective threads at an early stage. After step S43, theprocessor core terminates the context search processing.

For example, in the case where the context search processing is executedwith thread #1, thread #1 searches for a context with the thread #1specific search table. Search by thread #1 is in order from processingstep #4 to processing step #1 in the thread #1 specific search table. Inthe state of FIG. 16, thread #1 finds the pointer to context #2 and usescontext #2. In the case where context #2 has become absent, the pointerto context #1 is found, and context #1 is used. Further, in the casewhere context #1 has become absent, the thread #1 search table is in astate where an available context is absent, and thread #1 searches for acontext with a search table specific to a thread other than one's ownthread. In this case, search is in order from processing step #1 toprocessing step #4. Search by thread #1 is in the order of processingstep #1 of the thread #2 specific search table, processing step #1 ofthe thread #3 specific search table, processing step #2 of the thread #2specific search table, processing step #2 of the thread #3 specificsearch table, processing step #3 of the thread #2 specific search table,processing step #3 of the thread #3 specific search table, processingstep #4 of the thread #2 specific search table, and processing step #4of the thread #3 specific search table. In the case where the pointer tocontext #1 in FIG. 17 and FIG. 18 is absent, thread #1 finds the pointerto context #3 with the thread #2 specific search table and uses context#3.

In the context search processing described above, a thread specificsearch table specific to another thread is referenced to search for acontext, in the case where a context is absent, i.e., in the case wherethere are zero contexts. However for example, a thread specific searchtable specific to another thread may be referenced to search for acontext, in the case where there are less than or equal to apredetermined number of contexts.

With step S43 of the context search processing described above,unevenness in load between threads can be reduced based on the number ofcontexts available to respective threads. However, other than such aprocessing, there may be an adjustment by a light distribution threadshown in a modified example (see FIG. 34) described later.

FIG. 28 is a flowchart of a query execution plan execution processingaccording to Embodiment 1.

The query execution plan execution processing corresponds to step S39 inFIG. 26. The query execution plan execution processing is realized by aprocessor core executing a task assigned to a thread. A logicalfunctional unit that executes the query execution plan executionprocessing corresponds to the query execution plan execution unit 151.

The processor core acquires a page in the DB 206 by executing a DB pagefetch processing (see FIG. 29) (step S51). Next, the processor coredetermines, as true or false, whether data in the page that matches thesearch condition is present (step S52). An example is a searchprocessing within a higher-level page for a higher-level page of anindex or a search processing of a leaf page for a leaf page. In the casewhere data that matches the search condition is absent within data inthe page as a result (“false” in step S52), a processor terminates thequery execution plan execution processing.

In the case where data that matches the search condition is present(“true” in step S52), the processor core determines whether one piece ortwo or more pieces of data that match the search condition are present(step S53). In the case where one data that matches the search conditionis present as a result (“one” in step S53), the processor core proceedsto a processing of step S55. In the case where two or more pieces ofdata that match the search condition are present (“two or more” in stepS53), the processor core executes a new task addition processing (seeFIG. 30) (step S54) and proceeds to a processing of step S55.

In step S55, the processor core executes a processing with respect to apage of a DB in a processing step by the task. A processing with respectto a page of a DB is, for example, a processing of reading a page numberthat matches the search condition for a higher-level page of an index, aprocessing of reading a row ID that matches the search condition for aleaf page, or a processing of reading a column of a record for page of atable.

Next, the processor core determines the next page of the DB and aprocessing with respect to the DB page (step S56) and proceeds to aprocessing of step S57.

In step S57, the processor core releases the acquired DB page. Next, instep S58, the processor core determines whether or not the nextprocessing is present. Specifically, in the case where a processing stepcurrently performed is completed and the next processing step is absentin a processing block including the processing step, it is determined as“absent.” In the case where the next processing step is present as aresult (“present” in step S58), the processor core proceeds to aprocessing of step S51. In the case where the next processing is absent(“absent” in step S58), the processing result is passed to the queryexecution unit 144 (step S59), and the query execution plan executionprocessing is terminated.

Determination of the next DB page and the processing with respect to theDB page will be described with an example of a case where an indexsearch of the Part table is performed with c1=130 as the searchcondition with respect to the DB 206 shown in FIG. 4 to FIG. 7.

In the case where the index search is being started for the first time,the processor core determines a root page (page with the page number“P1”) of an index as the next DB page, determines a search processingwithin a higher-level page to search for a key of “130” with respect tothe page as a processing with respect to the DB page, and starts theprocessing. The processor core reads page P1 in step S51 and searchesfor an entry including c1 “130” within the page P1 in step S52. Oneentry including c1 “200” is to be found. Therefore, in step S55 and stepS56, a search processing within a higher-level page with respect to pageP3 that is the next processing is determined as a processing withrespect to a DB page. In step S51 to step S55, a processing with respectto page P3 is performed. The processor core reads page P3, searches foran entry including c1 “130” in the page P3, and finds a pointer to pageP8 in the entry including c1 “130.” As a result, page P8 is determinedas the next DB page, and a search processing within a leaf page withrespect to the page P8 is determined as a processing with respect to aDB page.

In step S51 to step S53, the processor core reads page P8, searches foran entry including c1 “130” in the page P8, and finds the page “P100” ofthe Part table and the slot number “2.” Since there are three pieces ofdata that match the condition, the new task addition processing (stepS54) is performed in order to perform processing of two pieces of dataother than data processed in the task. In this embodiment, dataprocessed in the task is assumed as first data, page P100 of the Parttable is determined as the next DB page in step S56, and a processing ofacquiring a record for the slot number 2 with respect to the page P100is determined as a processing with respect to a DB page.

FIG. 29 is a flowchart of a DB page fetch processing according toEmbodiment 1.

The DB page fetch processing corresponds to step S51 of the queryexecution plan execution processing (FIG. 28). The DB page fetchprocessing is realized by a processor core executing a task assigned toa thread.

The processor core searches for a buffer page (DB buffer page)corresponding to a DB page of a fetch target in the DB buffer managementunit 147 (step S61) and checks the presence or absence of thecorresponding DB buffer page (step S62).

In the case where the corresponding DB buffer page is present as aresult (“present in step S62), the processor core determines whether ornot reading of the page from the DB 206 is completed (step S63). In thecase where reading is completed (“complete” in step S63), the DB pagefetch processing is terminated. In the case where reading is notcompleted (“not complete” in step S63), processing proceeds to step S66.

In the case where the corresponding DB buffer page is absent (“absent”in step S62), the processor core acquires a free DB buffer page from theDB buffer management unit 147 (step S64), issues a DB page read requestwith respect to the DB 206 for reading the corresponding page into thefree DB buffer page (step S65), and proceeds to a processing of stepS66.

In step S66, the processor core waits for reading of the page to becompleted. The processor core may employ a scheme of executing anotherprocessing even if reading of a page is not completed, i.e.,asynchronous I/O, without employing a scheme of waiting until reading ofa page is completed, i.e., synchronous I/O. For example, the processorcore interrupts processing of a task being executed to cause a waitingstate and reattaches task execution state information to a waiting list.Completion of reading of a corresponding page is checked by a differentthread (or different task). In the case where the different thread(processor core executing the different thread) has checked completionof reading of the page, the task execution state information of the taskmay be reattached to a ready list to resume processing of the task.

In this manner, employing asynchronous I/O enables the processor core toperform execution of another task without waiting for completion ofreading of the page and allows processing efficiency in the DBMS 141 tobe improved. In the case where reading has been completed, the processorcore terminates the DB page fetch processing.

FIG. 30 is a flowchart of a new task addition processing according toEmbodiment 1.

The new task addition processing corresponds to step S54 of the queryexecution plan execution processing (FIG. 28). The new task additionprocessing is intended and executed for data other than one data (e.g.,first data) within matching data, in the case where two or more piecesof data that match the condition are present in step S53.

The processor core creates the context 82 based on data of a processingtarget (step S71). Next, the processor core executes a context sharingdetermination processing (see FIG. 31) for determining whether or notthe created context 82 is to be shared between threads (step S72). Next,the processor core executes a context registration processing (see FIG.32) of registering the created context 82 in the context managementinformation 80 (step S73).

Next, the processor core determines whether or not generating a new taskis possible (step S74). Whether or not generating a new task is possiblecan be determined by, for example, determining whether or not the numberof generated tasks in the DBMS 141 has reached an upper limit value ofthe number of tasks up to which generation is possible.

In the case where task generation is possible as a result (“possible” instep S74), the processor core executes a task generation processing (seeFIG. 33) for generating a new task (step S75) and terminates the newtask addition processing. In the case where task generation is notpossible (“not possible” in step S74), the new task addition processingis terminated without generating a task.

FIG. 31 is a flowchart of a context sharing determination processingaccording to Embodiment 1.

The context sharing determination processing corresponds to step S72 ofthe new task addition processing (FIG. 30). The context sharingdetermination processing is realized by a processor core executing atask assigned to a thread.

The processor core references an inter-thread sharing flag of aprocessing step relating to the generated context (step S81). In thecase where the inter-thread sharing flag is set to the processing stepas a result (“flag setting present” in step S81), it is determined bythe processor core as inter-thread sharing in which the context is madeavailable to a plurality of threads (step S82) and terminates thecontext sharing determination processing. In the case where theinter-thread sharing flag is not set to the processing step (“flagsetting absent” in step S81), it is determined by the processor core asnot inter-thread sharing in which the context is made available to onethread (step S83), and the context sharing determination processing isterminated.

In the context sharing determination processing, whether or not thegenerated context is to be shared between threads is determined based onthe inter-thread sharing flag. However, this is not limiting. Forexample, the processor core may determine whether or not the generatedcontext is to be shared between threads based on the execution state ofthe DBMS 141.

For example, as the execution state of the DBMS 141, the number ofcurrently existing tasks of the DBMS 141 is employed. It may be suchthat the processor core determines the generated context is to be sharedbetween threads in the case where the number of currently existing tasksis less than or equal to a predetermined number and determines thegenerated context to be not shared between threads in the case where thenumber of currently existing tasks is not less than or equal to thepredetermined number.

It may be such that the intermediate result 82 b included in a contextis employed as the execution state of a DBMS, and the processor coredetermines the generated context is to be shared between threads in thecase where the data volume of the intermediate result 82 b included inthe context is less than or equal to a predetermined volume anddetermines the generated context to be not shared between threads in thecase where the data volume of the intermediate result 82 b included inthe context is not less than or equal to the predetermined volume.

FIG. 32 is a flowchart of a context registration processing according toEmbodiment 1.

The context registration processing corresponds to step S73 of the newtask addition processing (FIG. 30). The context registration processingis realized by a processor core executing a task assigned to a thread.

The processor core registers a created context in a management list ofthe context management information 80 (step S91). Specifically, theprocessor core connects the created context behind the last contextcoupled to the management list.

Next, the processor core checks the result of the context sharingdetermination processing (see FIG. 31) (step S92). In the case where theresult is inter-thread sharing as a result (“shared” in step S92), apointer to the created context is registered in a plurality of threadspecific search tables, and the context registration processing isterminated. In this embodiment, a pointer to the context is registeredin all search tables specific to a thread that executes a DB accessprocessing (step S93). In addition, a pointer to the context may beregistered in a particular thread specific search table.

A case of registering a pointer to the context in a particular threadspecific search table will be described. For example, a thread specificsearch table for registration is specified based on hardwareconfiguration information of a computer. For the hardware configurationinformation, a processor configuration, a cache configuration, or amemory configuration is conceivable. For example, in a plurality ofthreads executed by a plurality of processor cores in one processor,registration is performed in a thread specific management table specificto a thread corresponding to the plurality of threads with the smallesttotal of the task generable number of an available context. In thisembodiment, consider a situation where a processor core executing thread#2 and a processor core executing thread #3 are of the same processor,the processor differs from a processor executing thread #1, and apointer to context #1 is registered in the thread specific search tableof thread #2 and the thread specific search table of thread #3. In thecase where new context #4 with respect to processing step #1 isgenerated, registration is performed in a search table specific to athread thread executed by a processor core of the processor with fewercontexts. In this case, registration is performed in the thread specificsearch table of thread #1. In this example, registration is performed inone thread specific search table. However, in the case where a processorwith a processor core executing thread #1 is also executing a threadthat executes the DB access processing, registration is performed in aplurality of thread specific search tables.

Alternatively, registration may be performed in a thread specificmanagement table specific to a thread corresponding to a plurality ofthreads corresponding to a processor including a processor core that hasgenerated a context. In a plurality of threads executed by a pluralityof processor cores in one processor, registration may be performed in athread specific management table specific to a thread corresponding tothe plurality of threads with a small total of available contexts.Registration may be performed in a thread specific management table of aplurality of threads executed by a processor core sharing a cache withina processor. Registration may be performed in a thread specificmanagement table of a plurality of threads executed by a processor coreclose to a memory in which a context is recorded. Registration may beperformed in a thread specific management table of a plurality ofthreads executed by a processor core close to a memory in which a DBbuffer page referenced upon use of a context is recorded.

In the case where the result is not inter-thread sharing (“not shared”in step S92), the processor core registers a pointer to one threadspecific search table and terminates the context registrationprocessing. In this embodiment, a pointer to the created context isregistered in a thread specific search table specific to a thread (one'sown thread) executed by itself (step S94) and terminates the contextregistration processing. Alternatively, registration may be performed ina thread specific search table with the fewest available contexts, orregistration may be performed in a thread specific search table with thesmallest total of task generable number of an available context.

FIG. 33 is a flowchart of a task generation processing according toEmbodiment 1.

The task generation processing corresponds to step S75 of the new taskaddition processing (FIG. 30). The task generation processing isrealized by a processor core executing a task assigned to a thread.

Next, the processor core checks the result of the context sharingdetermination processing (see FIG. 31) (step S101). In the case wherethe result is inter-thread sharing (“inter-thread sharing” in stepS101), the processor core generates a task and assigns the task to twoor more threads corresponding to a thread specific search table in whicha pointer of a context is registered (step S102). The upper limit of thetotal of tasks to be generated is the generable number for a context.The number of tasks assigned to each thread is a number obtained bydividing the generable number for the context by the number of threads.Then, the processor core terminates the task generation processing.

In the case where the result is not inter-thread sharing (“notinter-thread sharing” in step S101), the processor core generates a taskand assigns the task to one thread corresponding to a thread specificsearch table in which a pointer of a context is registered (step S103).The upper limit of the number of tasks to be generated is the generablenumber for a context. A thread to which a task is assigned may be one'sown thread executed by the processor core or may be a thread other thanone's own thread. After step S103, the processor core terminates thetask generation processing.

Next, a modified example of this embodiment will be described.

In the embodiment described above, the query execution unit 144 mayexecute a load balance processing shown below.

FIG. 34 is a flowchart of the load balance processing according to themodified example.

The load balance processing is executed by the query execution unit 144and is specifically realized by a processor core executing a thread(light distribution thread) other than a thread for performing a DBprocessing. The load balance processing is started after the clientcommunication control unit 142 has received a query.

The processor core determines whether or not a query processing has beenterminated (step S111). In the case where the query processing has beenterminated (“terminated” in step S111), the load balance processing isterminated.

In the case where the query processing has not been terminated (“notterminated” in step S111), the processor core calculates the total ofthe task generable number in an available context from each threadspecific search table (step S112).

Next, the processor core determines whether or not unevenness is presentin the total of the task generable number up to which generation ispossible by each thread (step S113). The processor core may determinethat unevenness is present in the case where the task generable numberis less than or equal to a predetermined number (e.g., zero), forexample.

In the case where unevenness is absent in the total of the taskgenerable number up to which generation is possible by each thread as aresult (“absent” in step S113), processing proceeds to step S115.

In the case where unevenness is present in the total of the taskgenerable number up to which generation is possible by each thread(“present” in step S113), the processor core reduces the unevenness inthe total of the task generable number up to which generation ispossible by each thread, by changing the position of a context, i.e.,changing a thread specific search table storing a pointer with which acontext is referenced to a different thread specific search table.Specifically, a pointer of a context made available by a thread specificsearch table specific to a thread with the largest total of the taskgenerable number is registered in a thread specific search tablespecific to a thread with a small total of the task generable number.Then, the processor core proceeds to a processing of step S115.

In step S115, the processor core causes the load balance processing tosleep for a predetermined time and proceeds to a processing of stepS111.

With the load balance processing, load with respect to respectivethreads can be distributed appropriately.

In the load balance processing described above, change of a thread thatuses a context is performed based on unevenness in the total of the taskgenerable number up to which generation is possible by each thread.However, it may be such that the load of a thread is kept track of and athread that uses a context is changed based on the execution staterelating to a thread, other than unevenness of the total of the taskgenerable number. For example, it may be such that a cost calculationfor each thread is performed, and a thread that uses a context ischanged based on the cost. As an example of the cost calculation, thefollowing value is conceivable. The cost of a context is assumed fromthe context as a product of the number of processing steps to beprocessed and the task generable number, and the total of cost of anavailable context is assumed from the thread as the cost of the thread.

The load balance processing may be executed by a thread for performing aDB processing. For example, execution may be at the time of terminationof a thread (in the case where it is determined as “absent” in step S32)or at the time of termination of a task (in the case where it isdetermined as “absent” in step S37). In this case, the load balanceprocessing is executed from step S112 to step S114.

Embodiment 2

Embodiment 2 will be described below. Differences from Embodiment 1 willbe mainly described, and description on points common with Embodiment 1will be omitted or simplified.

FIG. 35 shows the configuration of a computer system according toEmbodiment 2.

An application server (AP server) 3502 is connected, so as to be capableof communication via a communication network 3512, to the computer(hereinafter, DE server) 100 on which the DBMS 141 runs. The DB server100 is coupled to the external storage apparatus 200 be capable ofcommunication via the communication network 300. A user terminal (clientterminal) 3501 is coupled to the AP server 3502 to be capable ofcommunication via a communication network 3511. The DB server 100executes the DBMS 141 that manages the DB 206. The external storageapparatus 200 stores the DB 206. The AP server 3502 executes an AP thatissues a query with respect to the DBMS 141 executed by the DB server100. The user terminal 3501 makes a request to an AP executed by the APserver 3502. Multiple user terminals 3501 or the AP servers 3502 mayexist.

An AP server management terminal 3503 is coupled to the AP server 3502via a communication network 3514. A DB server management terminal 3504is coupled to the DB server 100 via a communication network 3515. Astorage management terminal 3505 is coupled to the external storageapparatus 200 via a communication network 3516. The AP server managementterminal 3503 is a terminal that manages the AP server 3502. The DBserver management terminal 3504 is a terminal that manages the DB server100. The storage management terminal 3505 is a terminal that manages theexternal storage apparatus 200. A DB server administrator or user mayperform setting relating to the DBMS 141 from the DB server managementterminal 3504. At least two of the management terminals 3503 to 3505 maybe common (integrated). At least two of the communication networks 3511,3512, 3514, 3515, 3516, and 300 may be common (integrated).

In Embodiment 2, processing is executed in the following manner, forexample.

(S121) The user terminal 3501 issues a request (hereinafter, userrequest) to the AP server 3502.

(S122) The AP server 3502 generates a query according to the userrequest received in S121. The generated query is issued to the DB server100.

(S123) The DB server 100 accepts the query from the AP server 3502 andexecutes the received query. The DB server 100 issues a datainput-output request (e.g., data read request) necessary in theexecution of the received query to the external storage apparatus 200.In the execution of one query, the DB server 100 may concurrently issuea plurality of data input-output requests. Therefore, the DB server 100may concurrently perform a request of S123 a plurality of times in theexecution of one query.

(S124) The external storage apparatus 200 responds to the DB server 100regarding the data input-output request issued in S123. The externalstorage apparatus 200 may concurrently perform a response of S124 aplurality of times.

(S125) The DB server 100 generates and transmits, to the AP server 3502,an execution result of the query.

(S126) The AP server 3502 transmits the execution result of the query. Areply with respect to the user request received in S121 according to theexecution result is transmitted to the user terminal 3501.

There may be a plurality of simultaneous user requests issued to the APserver 3502 or queries issued to the DB server.

The descriptions above are based on the embodiments. However, thepresent invention is not limited to the embodiments described above, andapplications to other various forms are possible.

REFERENCE SIGNS LIST

-   141 Database management system (DBMS)

1. A database management system for being realized by a computerincluding a processor core and for managing a database, comprising: aquery reception unit being configured to receive a query to thedatabase; a query execution plan generation unit being configured togenerate a query execution plan including information representing aprocessing step necessary for executing the received query and anexecution procedure of the processing step; and a query execution unitbeing configured to execute the received query based on the generatedquery execution plan, in an execution of the accepted query, dynamicallygenerate a task for executing a processing step and execute thedynamically generated task, the query execution unit being configured toexecute a task in a plurality of threads executed by a processor core inan execution of the received query, execute a plurality of tasks in onethread executed by the processor core, and when newly generating a task,generate a context and execute the generated task based on the generatedcontext, and the context being information including first informationshowing a processing step for starting an execution in the newlygenerated task is which of one or more processing steps represented bythe query execution plan, second information relating to an accessdestination for data required in a processing step shown by the firstinformation, and third information relating to data necessary forgenerating a result by the newly generated task.
 2. The databasemanagement system according to claim 1, wherein the query execution plangeneration unit is configured to determine whether a context relating tothe each processing step is to be shared between a plurality of threadsor to be not shared between a plurality of threads, and wherein thequery execution unit is configured to manage the context based on adetermination result.
 3. The database management system according toclaim 2, wherein the query execution plan generation unit is configuredto determine whether a context relating to the processing step is to beshared between a plurality of threads or to be not shared between aplurality of threads, based on a preceding or subsequent relation of theprocessing step with another processing step in the query executionplan.
 4. The database management system according to claim 2, wherein adata read request is issued with asynchronous I/O with respect to thedatabase in a task assigned to a thread executed by the processor core,wherein a processor core that executes the thread is configured toperform execution of another executable task after issuance of a dataread request in the task and before reading of data corresponding to thedata read request is completed, and wherein a processor core thatexecutes the thread is configured to resume execution of the task afterreading of data corresponding to the data read request in the task hasbeen completed.
 5. The database management system according to claim 2,wherein the number of identical numbers of the threads capable of beingassigned with a task for executing the processing step is identical tothat of the processor cores, and processor cores that execute respectivethreads are each set as different processor cores.
 6. The databasemanagement system according to claim 2, wherein, in a case where aplurality of processing blocks including concurrently executableprocessing steps are included in the query execution plan, the queryexecution plan generation unit is configured to determine that a contextrelating to a processing step at a start of the processing block is tobe shared between a plurality of threads and determine that a contextrelating a processing step other than the processing step is to be notshared between threads.
 7. The database management system according toclaim 2, wherein, in a case where a plurality of processing blocksincluding concurrently executable processing steps are included in thequery execution plan, the query execution plan generation unit isconfigured to determine that a context relating to a processing stepwith a predetermined number or greater number of subsequent processingsteps in the processing block is to be shared between a plurality ofthreads and determine that a context relating to a processing step witha less number than a predetermined number of subsequent processing stepsis to be not shared between threads.
 8. The database management systemaccording to claim 2, wherein, in a case where a number of contextsavailable to one thread is below a predetermined number, the queryexecution unit is configured to use a context available to anotherthread for a task assigned to the one thread.
 9. The database managementsystem according to claim 2, wherein, in a case where an execution staterelating to the plurality of threads has become a predetermined state,the query execution unit is configured to change a context available toone thread to a context available to another thread so that a differencein numbers of available contexts between threads becomes smaller than apredetermined number.
 10. The database management system according toclaim 9, wherein a predetermined state of an execution state of theplurality of threads is a state where a difference in the numbers ofavailable contexts between threads has become greater than or equal to apredetermined number.
 11. The database management system according toclaim 1, wherein the query execution unit is configured to determinewhether or not a context is to be shared between a plurality of threadsbased on an execution state of a database management system, and whereinthe query execution unit is configured to cause the context to be sharedbetween a plurality of threads in a case where the context is determinedto be shared between a plurality of threads, and cause the context to beused by one thread in a case where the context is determined to be notshared between a plurality of threads.
 12. The database managementsystem according to claim 11, wherein an execution state of the databasemanagement system is a number of existing tasks in the databasemanagement system, and wherein the query execution unit is configured todetermine that the context is to be shared by a plurality of threads ina case where the number of existing tasks is less than or equal to apredetermined number and determine that the context is not to be sharedin a case where the number of existing tasks is not less than or equalto a predetermined number.
 13. The database management system accordingto claim 12, wherein an execution state of the database managementsystem is third information included in a context, and wherein the queryexecution unit is configured to determine that the context is to beshared by a plurality of threads in a case where a data volume of thirdinformation included in the context is less than or equal to apredetermined volume and determines that the context is not to be sharedin a case where a data volume of third information included in thecontext is not less than or equal to a predetermined volume.
 14. Thedatabase management system according to claim 1, wherein the queryexecution unit is configured to cause the context to be available to anyof the threads, and wherein the query execution unit is configured tochange a context available to one thread to a context available toanother thread so that a difference in the numbers of available contextsbetween threads becomes smaller than a predetermined number in a casewhere a difference in numbers of available contexts between threads hasbecome greater than or equal to a predetermined number.
 15. A computercomprising: a storage resource; and a control device including one ormore processors including one or more processor cores which is coupledto the storage resource, the control device being configured to receivea query to a database, generate a query execution plan includinginformation representing a processing step necessary for executing thereceived query and an execution procedure of the processing step,execute the received query based on the generated query execution plan,in an execution of the received query, dynamically generates a task forexecuting a processing step and execute the dynamically generated task,the control device being configured to execute a task in a plurality ofthreads executed by a processor core in an execution of the receivedquery, execute a plurality of tasks in one thread executed by theprocessor core, and when newly generating a task, generate a context andexecute the generated task based on the generated context, and, thecontext being information including first information showing aprocessing step for starting an execution in the newly generated task iswhich of one or more processing steps represented by the query executionplan, second information relating to an access destination for datarequired in a processing step shown by the first information, and thirdinformation relating to data necessary for generating a result with thenewly generated task.
 16. A database management method for managing adatabase, comprising: (a) accepting a query to the database; (b)generating a query execution plan including information representing aplurality of one or more processing steps necessary for executing thereceived query and an execution procedure of the one or more processingsteps; and (c) executing the received query by dynamically generating atask for executing a processing step and executing the dynamicallygenerated task based on the generated query execution plan, in (c),executing a task in a plurality of threads executed by a processor corein an execution of the received query, executing a plurality of tasks inone thread executed by the processor core, and when newly generating atask, generating a context and executing the generated task based on thegenerated context, and the context being information including firstinformation showing a processing step for starting an execution in thenewly generated task is which of one or more processing stepsrepresented by the query execution plan, second information relating toan access destination for data required in a processing step shown bythe first information, and third information relating to data necessaryfor generating a result with the newly generated task.